package com.example.tts;

import java.util.Locale;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;

public class TTSDemo extends Activity implements OnInitListener{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Intent checkIntent = new Intent();
        checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
        startActivityForResult(checkIntent, 0);
        tts = new TextToSpeech(this, this);

    }
    
    private TextToSpeech tts;

    @Override
	public void onInit(int arg0) {
		// TODO Auto-generated method stub
		String speech1 = "How are you?";
		String speech2 = "I hope you are fine.";
		tts.setLanguage(Locale.US);
		tts.speak(speech1, TextToSpeech.QUEUE_FLUSH, null);
		tts.speak(speech2, TextToSpeech.QUEUE_ADD, null);
	}
}